<?php
/**
 * 首页控制器
 * @author maniac
 */
namespace app\manage\controller;

use app\facade\AdminMenus;
use app\facade\Users;
use app\facade\UserRoles;
use app\facade\Index AS IndexFacade;

class Index extends Base
{    
    /**
     * 后台框架首页
     */
    public function index()
    {
        $menus = AdminMenus::formatMenus(session('role_id', '', session_prefix()), ['status' => 0]);
        if ($menus) {
            $menus = recursion_many_array($menus);
        }

        // 获取管理员管理栏目，生成栏目树菜单
        $userid        = session('userid', '', session_prefix());
        $admin_columns = Users::getAdminColumns($userid);
        $trees         = generate_tree_html($admin_columns);
        
        return $this->fetch('', [
            'menus' => $menus,
            'trees' => $trees,
        ]);
    }
    
    /**
     * 欢迎界面
     */
    public function welcome()
    {
        $statics = IndexFacade::statics();
        return $this->fetch('', [
            'statics' => $statics,
        ]);
    }
}
